/*
 * Copyright (C) 2020-present, kinbug All rights reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.gitee.kinbug.sniper.web.util;

import com.gitee.kinbug.sniper.common.entity.Bar;
import com.gitee.kinbug.sniper.common.enums.CandleEnum;
import com.gitee.kinbug.sniper.common.enums.SymbolEnum;
import com.huobi.wss.event.MarketKLineReqResponse;
import com.huobi.wss.event.MarketKLineSubResponse;

/**
 * -类拷贝
 * @ClassName: BeanCopyUtil
 * @author kinbug
 * @date 2020-12-3
 */
public class BeanCopyUtil {

	/**
	 * - DataBean 转 Bar
	 * @Title DataBeanToBar
	 * @param  参数
	 * @return void 返回类型
	 * @throws
	 */
	public static Bar dataBeanToBar(MarketKLineReqResponse.DataBean data, SymbolEnum symbolEnum,CandleEnum candleEnum) {
		return Bar.builder()
				.id(data.getId())
				.high(data.getHigh())
				.open(data.getOpen())
				.low(data.getLow())
				.close(data.getClose())
				.tradeTurnover(data.getTradeTurnover())
				.symbol(symbolEnum.getCode())
				.candleEnum(candleEnum)
				.build();
	}
	
	/**
	 * - DataBean 转 Bar
	 * @Title DataBeanToBar
	 * @param  参数
	 * @return void 返回类型
	 * @throws
	 */
	public static Bar tickBeanToBar(MarketKLineSubResponse.TickBean data , SymbolEnum symbolEnum,CandleEnum candleEnum) {
		return Bar.builder()
				.id(data.getId())
				.high(data.getHigh())
				.open(data.getOpen())
				.low(data.getLow())
				.close(data.getClose())
				.tradeTurnover(data.getTradeTurnover())
				.symbol(symbolEnum.getCode())
				.candleEnum(candleEnum)
				.build();
	}
}
